Totals and Subtotals can be added in a to add meaning to the data it displays.
Use the steps below to learn how to set totaling and subtotaling in each data region. These steps assume that you have already added a Page Report/RDL Report template and connected it to a data source. See Adding an ActiveReport to a Project, Connect to a Data Source and Add a Dataset for more information.
|
Note: This topic uses examples from the tables in the Reels database. By default, in ActiveReports, the Reels.mdb file is located at [User Documents folder]\GrapeCity Samples\ActiveReports 9\Data\Reels.mdb. |
To add Totals and Subtotals in a Table
You can easily calculate and add totals and subtotals in a Table data region and its groups. Go through the sections below to learn adding Totals and SubTotals.
To add a subtotal to a table group
- From the Visual Studio toolbox, drag and drop a Table data region onto the .
- From the Report Explorer, drag a numeric field (Like InStock) onto the detail row of the Table. This field repeats for each row of data in the associated dataset.
- Follow the steps below to add a grouping to the table data region.
- Click inside the table to reveal the row and column handles along the left and top edges of the table.
- Right-click in the row handles along the left edge of the table and select Insert Group.
- On the Groups dialog that appears, set a Group on expression through which you want to group the data.
- Click the OK button in the lower right corner to close the dialog and apply the change. A new pair of rows appears between the detail row and the header and footer rows.
- From the Report Explorer, drag and drop the same numeric field onto the GroupFooter row.
- Double click the textbox containing the field you just dropped onto the GroupFooter row and add a Sum function to its expression to calculate the total. [i.e. change =Fields!InStock.Value to =Sum(Fields!InStock.Value)]
- Go to the Preview Tab to see the subtotals appearing below each group of data that the Table data region displays.
To add a grand total to a table
- Drag the same numeric field used above onto the TableFooter row at the bottom of the table.
- Double click the textbox containing the field you just dropped onto the GroupFooter row and add a Sum function to its expression to calculate the total. [i.e. change =Fields!InStock.Value to =Sum(Fields!InStock.Value)]
- Go to the Preview Tab to see that the new textbox supplies a grand total for the table.
To add Totals and Subtotals in a List
You can easily calculate and add totals and subtotals in a List data region. You can add subtotals using detail grouping, and grand totals for a list can be easily added to the body of the report just below the list.Go through the sections below to learn adding Totals and SubTotals.
To add a subtotal to a list
- From the Visual Studio toolbox, drag and drop a List data region onto the design surface.
- In the , drag and drop a numeric field (like Price)onto a list data region. With no changes, this field would repeat for each row of data in the associated dataset.
- Double click the textbox containing the field you just dropped and add a Sum function to its expression to calculate the total. [i.e. change =Fields!Price.Value to =Sum(Fields!Price.Value)]
|
Note: If you preview the report at this point, you will notice that the summary field renders the grand total for the dataset after each sales amount, which is probably not the behavior we want. |
- Follow the steps below to add a detail grouping to the List data region.
- Right-click the list and select Properties.
- On the Detail Grouping page, select a Group on expression (like AccountNumber) through which you want to group the data.
- Click the OK button in the lower right corner to close the dialog and apply the change.
- Go to the Preview tab to view the report, you will see a subtotal displaying next to every group of data that is displayed in the report.
To add a grand total to a list
- Drag the same numeric field that shows subtotals in your list onto the body of the report just below the list data region.
- Double click the textbox containing the field you just dropped and add a Sum function to its expression to calculate the Grand total.
- Go to the Preview Tab to the new textbox supplying a grand total for the List.
To add Totals and Subtotals in a BandedList
You can easily calculate and add totals and subtotals in a BandedList data region and its groups. Go through the sections below to learn adding Totals and SubTotals.
To add a subtotal to a banded list
- From the Visual Studio toolbox, drag and drop a BandedList data region onto the design surface.
- From the Report Explorer, drag a numeric field (Like InStock) onto the detail band of the banded list. This field repeats for each row of data in the associated dataset. This action also sets the DataSetName property of the BandedList to the name of the dataset from which you dragged the field.
- Follow the steps below to add a grouping to the BandedList data region.
- Right-click the list and select Insert Group.
- On the Groups dialog that appears, select a Group on expression (like StorePrice) through which you want to group the data.
- Click the OK button in the lower right corner to close the dialog and apply the change. A new pair of bands appears between the detail band and the header and footer bands.
- From the Report Explorer, drag and drop the same numeric field into the GroupFooter band.
- Double click the textbox containing the field you just dropped and add a Sum function to its expression to calculate the total. [i.e. change =Fields!InStock.Value to =Sum(Fields!InStock.Value)]
- Go to the Preview tab to view the report, you will see a subtotal displaying below every group of data that is displayed in the report.
To add a grand total to a banded list
- Drag the same numeric field used above onto the BandedListFooter band at the bottom of the banded list.
- Double click the textbox containing the field you just dropped and add a Sum function to its expression to calculate the total. [i.e. change =Fields!InStock.Value to =Sum(Fields!InStock.Value)]
- Go to Preview Tab to see the new textbox supplying a grand total for the BandedList.
To add Totals and Subtotals in a Matrix
You can easily calculate and add totals and subtotals in a matrix data region and its groups. Go through the sections below to learn adding Totals and SubTotals.
To add a subtotal to a matrix group
- From the Visual Studio toolbox, drag and drop a Matrix data region onto the design surface.
- In the , right-click a row and select Add Row Group/ Add Column Group.
- In the Matrix data region, right-click a row header cell or column header cell and select Subtotal. A new column or row with a header labeled Total is added.
- Now drag and drop a numeric field (like InStock) onto the Matrix data region and go to the Preview tab to view the result.
To add a grand total to a matrix
- Follow the steps above to add subtotals to both the row header and the column header.
- The bottom right cell of the rendered matrix reflects the grand total.